<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #demo{
            width: 200px;
            height: 200px;
            background-color: pink;
        }
    </style>
</head>
<body>
<div id="demo"></div>
<button id="btn">改变宽度</button>
</body>
<script type="text/javascript">
    var demo = document.getElementById("demo");
    var btn = document.getElementById("btn");
    btn.onclick = function(){
        demo.style.width = "400px";
    }
</script>
</html>